<template>
    <z-paging v-if="padding_show" :show-refresher-when-reload="true"  show-refresher-update-time  ref="paging" v-model="dataList" @query="queryList">
		<!-- z-paging默认铺满全屏，此时页面所有view都应放在z-paging标签内，否则会被盖住 -->
		<!-- 需要固定在页面顶部的view请通过slot="top"插入，包括自定义的导航栏 -->
		<view slot="top" class="">
			<u-navbar back-text=" " :title="title"></u-navbar>
			<view class="search_box_search">
				<view class="search_input">	
					<input class="input_font" v-model="code" placeholder="请输入快递单号" type="text" />
				</view>	
				<image style="width: 64rpx; height: 64rpx;" @click="search" src="https://www.mengkahuyu.com/index_png/search_cion.png" mode=""></image>
			</view>
		</view>
        <view class="list" >
			<view v-for="(item,index) in dataList" :key="index" class="list_item">
				<view class="list_item_left">
					<span class="list_item_left_text uni-ellipsis"> 
						<span class="list_item_left_title">快递单号:</span> 
						{{item.code}}
					</span>
					<span  class="list_item_left_text"> 
						<span class="list_item_left_title">入库时间:</span> 
						{{item.add_time}}
					</span>
				</view>
				<view @click="navTo(kor_type=='kor'?'/pages/yuBao/yuBao?id='+item.id:'/pages/yuBao/yuBao_zh?id='+item.id)" class="list_item_right">
					认领
				</view>
			</view>
        </view>
    </z-paging>
</template>

<script>
    export default {
        data() {
            return {
				// v-model绑定的这个变量不要在分页请求结束中自己赋值，直接使用即可
				padding_show:false,
				code:'',
                dataList: [],
				title:'包裹认领',
				kor_type:''
            };
        },
		onShow() {
			var token = uni.getStorageSync('token')
			this.kor_type = uni.getStorageSync('kor_type')
			this.padding_show = false
			// console.log('onshow')
			setTimeout(()=>{
				this.padding_show = true
			},100)
			// if(token){	
			// 	setTimeout(()=>{
			// 		this.padding_show = true
			// 	},100)
			// 	// if(this.$refs.paging){
			// 	// 	this.$refs.paging.reload()	
			// 	// }
			// }
		},
        methods: {
			search(){
				this.$refs.paging.reload()
			},
			// @query所绑定的方法不要自己调用！！需要刷新列表数据时，只需要调用this.$refs.paging.reload()即可
            queryList(pageNo, pageSize) {
				// 此处请求仅为演示，请替换为自己项目中的请求
				var data = {
					page:pageNo,
					limit:pageSize,
					"code": this.code
				}
				var token = uni.getStorageSync('token')
				if(this.kor_type=='kor'){
					this.$wqzApi.Order_ClaimList(data).then(res=>{
						this.$refs.paging.complete(res.data.list);
					}).catch(err=>{
						this.$refs.paging.complete(false);
					})
				}else{
					this.$wqzApi.kor_Order_ClaimList(data).then(res=>{
						this.$refs.paging.complete(res.data.list);
					}).catch(err=>{
						this.$refs.paging.complete(false);
					})
				}
				
                
            },
			navTo(url){
				uni.navigateTo({
					url:url
				})
			},
        },	
    };
</script>
<style lang="scss" scoped>
	@import url(./index.scss);
</style>